package com.hqyj.goods.controller;


import com.hqyj.goods.dto.GoodsInfo;
import com.hqyj.goods.dto.InventoryInfo;
import com.hqyj.goods.entity.Goods;
import com.hqyj.goods.service.GoodsService;
import com.hqyj.storage.entity.Storage;
import com.hqyj.storage.service.StorageService;
import com.hqyj.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sdx2009
 * @since 2022-09-30
 */
@RestController
@RequestMapping("/api/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @Autowired
    private StorageService storageService;

    @PostMapping("inventoryIndex")
    public ResultUtils inventoryIndex(InventoryInfo inventoryInfo){
        HttpServletRequest request;
        return goodsService.inventoryIndex(inventoryInfo);
    }

    @PostMapping("selectInventory")
    public ResultUtils selectInventory(){
        return goodsService.selectInventory();
    }

    @PostMapping("inventoryOperation")
    public ResultUtils inventoryOperation(InventoryInfo inventoryInfo){
        return goodsService.inventoryOperation(inventoryInfo);
    }

    @PostMapping("selectStorageByType")
    public ResultUtils selectStorageByType(InventoryInfo inventoryInfo){
        return storageService.selectStorageByType(inventoryInfo.getGoodsType());
    }

    @PostMapping("joinStorage")
    public ResultUtils joinStorage(InventoryInfo inventoryInfo){
        return goodsService.joinStorage(inventoryInfo);
    }

    @PostMapping("outStorage")
    public ResultUtils outStorage(InventoryInfo inventoryInfo){
        return goodsService.outStorage(inventoryInfo);
    }

    @PostMapping("goodsIndex")
    public ResultUtils goodsIndex(GoodsInfo goodsInfo){
        return goodsService.goodsIndex(goodsInfo);
    }

    @PostMapping("selectGoods")
    public ResultUtils selectGoods(){
        return goodsService.selectGoods();
    }

    @PostMapping("addStorage")
    public ResultUtils addStorage(InventoryInfo inventoryInfo){
        return goodsService.addStorage(inventoryInfo);
    }


    @PostMapping("deleteGoods")
    public ResultUtils deleteGoods(InventoryInfo inventoryInfo){
        return goodsService.deleteGoods(inventoryInfo.getGoodsId());
    }
}
